package top.hjcwzx.wrench.mqtt.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import top.hjcwzx.wrench.mqtt.enums.MessageHandlerStrategyEnum;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

/**
 *
 * <p><b>描述：</b> mqtt配置</p>
 * <p><b>创建时间：</b> 2025-06-17 15:31</p>
 *
 * @author 胡锦程
 *
 */
@ConfigurationProperties(prefix = "wrench-kit.mqtt.config", ignoreInvalidFields = true)
public class MqttConfigProperties {

    /**
     * 协议
     */
    private String agreement = "tcp";

    /**
     * mqtt服务端IP
     */
    private String ip = "localhost";
    /**
     * mqtt服务端端口
     */
    private String port = "1883";
    /**
     * mqtt服务端用户名
     */
    private String username;
    /**
     * mqtt服务端密码
     */
    private String password;

    /**
     * 客户端ID
     */
    private String clientId = UUID.randomUUID().toString();

    /**
     * 自动重连
     */
    private Boolean autoReconnect = true;

    /**
     * 默认主题列表
     */
    private List<String> defaultTopics = new ArrayList<>();

    /**
     * 消息处理策略
     */
    private MessageHandlerStrategyEnum strategyEnum = MessageHandlerStrategyEnum.ANNOTATION_CALLBACK;

    public String getAgreement() {
        return agreement;
    }

    public void setAgreement(String agreement) {
        this.agreement = agreement;
    }

    public String getIp() {
        return ip;
    }

    public void setIp(String ip) {
        this.ip = ip;
    }

    public String getPort() {
        return port;
    }

    public void setPort(String port) {
        this.port = port;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getClientId() {
        return clientId;
    }

    public void setClientId(String clientId) {
        this.clientId = clientId;
    }

    public List<String> getDefaultTopics() {
        return defaultTopics;
    }

    public void setDefaultTopics(List<String> defaultTopics) {
        this.defaultTopics = defaultTopics;
    }

    public MessageHandlerStrategyEnum getStrategyEnum() {
        return strategyEnum;
    }

    public void setStrategyEnum(MessageHandlerStrategyEnum strategyEnum) {
        this.strategyEnum = strategyEnum;
    }

    public MqttConfigProperties() {
    }

    public MqttConfigProperties(String agreement, String ip, String port, String username, String password, String clientId, Boolean autoReconnect, List<String> defaultTopics, MessageHandlerStrategyEnum strategyEnum) {
        this.agreement = agreement;
        this.ip = ip;
        this.port = port;
        this.username = username;
        this.password = password;
        this.clientId = clientId;
        this.autoReconnect = autoReconnect;
        this.defaultTopics = defaultTopics;
        this.strategyEnum = strategyEnum;
    }

    public Boolean getAutoReconnect() {
        return autoReconnect;
    }

    public void setAutoReconnect(Boolean autoReconnect) {
        this.autoReconnect = autoReconnect;
    }
}
